package stringDemo;

import java.util.*;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

//给定一个字符串,输出其中最多的字符(使用map集合,更方便)
public class StringTest2 {
    static  int maxValue=0;
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str=scanner.nextLine();

        String maxKey="";
        HashMap<Character,Integer>hashMap=new HashMap<>();
        char[]targetCharOfString=str.toCharArray();
        for (Character numsOfChar:targetCharOfString){
            if (!hashMap.containsKey(numsOfChar)){
                hashMap.put(numsOfChar,1);
            }else {
                hashMap.put(numsOfChar,hashMap.get(numsOfChar)+1);
            }
        }
        /*
        Set<Character> characters = hashMap.keySet();
        Iterator<Character> iterator = characters.iterator();
        while (iterator.hasNext()){
            Character next = iterator.next();
            Integer value = hashMap.get(next);
            if (value>maxValue){
                maxValue=value;
            }
        }*/
        //获取最大的值
        Set<Map.Entry<Character, Integer>> entries = hashMap.entrySet();
        for (Map.Entry<Character,Integer> entry:entries){
            if (entry.getValue()>maxValue){
                maxValue=entry.getValue();

            }
        }
        //根据值找键
        hashMap.forEach(new BiConsumer<Character, Integer>() {
            @Override
            public void accept(Character character, Integer integer) {
                if (maxValue==(int)integer){
                    System.out.println(character+"--"+integer);
                }
            }
        });
    }

}
